package com.probox.common.entity.service.order;

import com.baomidou.mybatisplus.extension.service.IService;
import com.probox.customer.api.domain.CustomerGroupDefinitionQuery;
import com.probox.order.api.domain.OrderPostSaleVo;
import com.probox.common.entity.domain.order.OrderInfo;
import com.probox.common.entity.domain.order.OrderInfoParent;
import com.probox.common.entity.domain.order.OrderPostSale;
import com.probox.common.entity.domain.order.vo.PostSaleQuery;
import com.probox.product.api.domain.ProductOptVo;

import java.util.List;

/**
 * 订单售后Service接口
 *
 * @author hds
 * @date 2021-06-07
 */
public interface IOrderPostSaleService extends IService<OrderPostSale> {


    /**
     * 查询订单售后
     *
     * @param serviceUid 订单售后ID
     * @return 订单售后
     */
    public OrderPostSaleVo selectOrderServiceById(Long serviceUid);


    /**
     * 查询订单售后列表
     *
     * @param orderPostSale 订单售后
     * @return 订单售后集合
     */
    public List<OrderPostSale> queryList(OrderPostSale orderPostSale);


    /**
     * 新增订单售后
     *
     * @param orderPostSale 订单售后
     * @return 结果
     */
    public boolean insertOrderService(OrderPostSale orderPostSale);

    /**
     * 修改订单售后
     *
     * @param orderPostSale 订单售后
     * @return 结果
     */
    public boolean updateOrderService(OrderPostSale orderPostSale);

    /**
     * 批量删除订单售后
     *
     * @param serviceUids 需要删除的订单售后ID
     * @return 结果
     */
    public boolean deleteOrderServiceByIds(Long[] serviceUids);

    /**
     * 查询售后列表
     * @param query
     * @return
     */
    List<OrderPostSaleVo> getPostSaleList(PostSaleQuery query);

    /**
     * 查询售后明细详情
     * @param itemId
     * @return
     */
    OrderPostSaleVo getPostSaleDetail(Long itemId);

    /**
     * 统计
     * @param query
     * @return
     */
    int getPostSaleCount(PostSaleQuery query);

    /**
     * 取消售后
     * @param itemId
     * @return
     */
    boolean cancelPostSale(Long itemId);

    /**
     * 申请售后
     * @param vo
     * @return
     */
    boolean applyPostSale(OrderPostSaleVo vo);

    /**
     * 申请退款
     * @param parent
     * @param orderInfo
     * @param sale
     * @param subMchid
     * @return
     */
    boolean wechatRefund(OrderInfoParent parent, OrderInfo orderInfo, OrderPostSale sale, String subMchid);

    /**
     * 退款，退分润
     * @param parent
     * @param orderInfo
     * @param sale
     * @param refundAmount
     */
    public void refundCustomerFund(OrderInfoParent parent, OrderInfo orderInfo, OrderPostSale sale, Long refundAmount);

    /**
     * 同意处理
     * @param query
     * @return
     */
    boolean agreeFinish(PostSaleQuery query);

    /**
     * 用户退换货单号
     * @param query
     * @return
     */
    boolean addLogistic(PostSaleQuery query);

    /**
     * 售后审核
     * @param sale
     * @return
     */
    boolean auditSale(OrderPostSale sale);

    /**
     * 用户所有退款信息
     * @param itemUid
     * @return
     */
    List<OrderPostSaleVo> getOrderRefund(Long itemUid);

    Integer getOrderRefundCount(Long itemUid);

    /**
     * 用户退款统计
     * @param query
     * @return
     */
    List<ProductOptVo> getOptCount(CustomerGroupDefinitionQuery query);
}
